# 路由信息
import os

from fastapi import APIRouter, Header

from api.companys import company_router
# from api.logs import log_router
# from api.orders import order_router, suppliers_router, logistics_router
# from api.projects import project_router
# from api.stations import station_router
# from api.users import user_router, login_router, role_router
from api.depart.routers import depart_router
from api.experiment.router import experiment_router
from api.model.router import model_router
from api.user import user_router, code_router
from api.well.router import well_router
from api.projects.routers import project_router
from config import ROUTER_PREFIX  # 主路由前缀prefix
from fastapi import Response
from fastapi.responses import FileResponse
api_router = APIRouter(prefix=ROUTER_PREFIX)  # 主路由

from fastapi.responses import StreamingResponse


# async def test(str :str, token=Header("token")):

@api_router.get("/download", name="下载apk")
async def download(response: Response):
        APK_FILE_PATH = "../app_release.apk"
        # 获取当前文件所在目录的绝对路径
        current_directory = os.path.dirname(os.path.abspath(__file__))
        # 获取上一级目录的路径
        parent_directory = os.path.abspath(os.path.join(current_directory, os.pardir))
        # 构建文件的路径
        APK_FILE_PATH = os.path.join(parent_directory, "app_release.apk")
        return FileResponse(APK_FILE_PATH, media_type="application/vnd.android.package-archive", filename=os.path.basename(APK_FILE_PATH))


# api_router.include_router(login_router)
api_router.include_router(user_router)
api_router.include_router(code_router)
api_router.include_router(depart_router)
api_router.include_router(project_router)
# api_router.include_router(role_router)
# api_router.include_router(station_router)
# api_router.include_router(project_router)
api_router.include_router(company_router)
api_router.include_router(well_router)
api_router.include_router(experiment_router)
api_router.include_router(model_router)

# api_router.include_router(order_router)
# api_router.include_router(suppliers_router)
# api_router.include_router(logistics_router)
# api_router.include_router(log_router)
